
#ifndef COMPORT_H_
#define COMPORT_H_
/*
#include <QString>
#include <QDir>
#include <QList>
#include <QFileInfo>
#include <QListIterator>
*/

#define MAX_DEV_SIZE 128
#define CMD_MAX_SIZE 64

/* A Traiter
 - Joysticks
 - FT232 pour module OBD
 - I2C modules (2 types) (capteurs et Si4735)
 - GPS module
 - DPL modules (2 types IO8 et IO20)
 - Afficheur LCD Orbital Matrix
 - Module commande Servos
 */

class ComPort
{
  public:

	// Devices connus
	const static int LCD_LK = 99;

	ComPort(const char *dev, int baudrate, int stopbit);
	ComPort(int device);
	virtual ~ComPort();
	void openPort(void);
	void closePort(void);
	int getPort();

	// USB to I2C module
	int getUSBI2CFirmwareRevision();
	int readBytes(char *data, int numberOfBytes);
	int writeBytesToTwoByteAddressedI2CDevice(char address, char command1, char command2, char *data, int datalenght);
	int readBytesFromTwoByteAddressedI2CDevice(char address, char command1, char command2,  char *data, int bytesToRead);

	int writeBytesToOneByteAddressedI2CDevice(char address, char command, char *data, int datalenght);
    int readBytesFromOneByteAddressedI2CDevice(char address, char command, int numberOfBytesToRead);


	// LK series www.MatrixOrbital.com LCD Displays
	const char* findLCDLKtty();  // Chercher le ttyUSBx associe a "MO_LK" - A ameliorer avec le numero de serie
    void clearScreenLK();
    void setTextLK(const char *txt);
    void setCharacterLK(char car);
    void setCursorPositionLK(char row, char col);
    void blinkingBlockCursorOnLK();
    char readKeyLK();
    int readVersionNumberLK();
    int readModuleTypeLK();

    // DLP-IO8-G Commands
    char DLP_Ping();
    void DLP_ChannelHigh(int channel);
    void DLP_ChannelLow(int channel);
    void DLP_Channel8High();
    void DLP_Channel8Low();

  private:
    int com_port_fd;
	char *dev;
	int baudrate;
	int stopbit;
	int res;
	int key;
	char cmd[CMD_MAX_SIZE];
};

#endif /* COMPORT_H_ */
